package cn.itcast.ssm.controller;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import cn.itcast.ssm.po.Items;

public class ItemsController1 implements Controller{

	@Override
	public ModelAndView handleRequest(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		//调用service调用数据库查询商品列表，这里使用静态模拟
		List<Items> itemsList=new ArrayList<Items>();
		
		Items items1=new Items();
		items1.setName("联想笔记本");
		items1.setPrice(6000f);
		items1.setDetail("z460联想笔记本电脑");
		itemsList.add(items1);
		
		Items items2=new Items();
		items2.setName("苹果手机");
		items2.setPrice(5000f);
		items2.setDetail("ipnone 6s 苹果手机");
		itemsList.add(items2);
		
		//返回modelandview
		ModelAndView modelAndView=new ModelAndView();
		//相当于resuest的setAttribute,在jsp页面上通过itemsList取数据
		modelAndView.addObject("itemsList", itemsList);
		
		//设置view
		modelAndView.setViewName("/WEB-INF/jsp/items/itemsList.jsp");
		
		
		return modelAndView;
	}

}
